/*
 * @Author: moonwater 13812995013@163.com
 * @Date: 2025-03-05 19:15:24
 * @LastEditors: moonwater 13812995013@163.com
 * @LastEditTime: 2025-03-05 19:22:28
 * @FilePath: \盐师22Git仓库\day08\PrimeFactorization.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package day08;
import java.util.Scanner;

public class PrimeFactorization {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // 提示用户输入一个15以内的正整数
        System.out.print("请输入一个15以内的正整数: ");
        int number = scanner.nextInt();
        
        // 检查输入是否有效
        if (number <= 0 || number > 15) {
            System.out.println("输入无效，请输入一个15以内的正整数。");
            return;
        }
        
        // 输出分解质因数的结果
        System.out.print(number + " = ");
        factorize(number);
    }
    
    // 分解质因数的函数
    public static void factorize(int number) {
        for (int i = 2; i <= number; i++) {
            while (number % i == 0) {
                System.out.print(i);
                number /= i;
                if (number != 1) {
                    System.out.print(" * ");
                }
            }
        }
        System.out.println();
    }
}